<?php

  /*

      TravianWAP
      Copyright (c) 2007-08 by Ananas - All rights reserved
      http://n00bz.biz/travianwap/
      Contact: uroskn@gmail.com

      --------------------------------------------------------------------------

      This program is free software: you can redistribute it and/or modify
      it under the terms of the GNU  General Public License as published by
      the Free Software Foundation, either version 3 of the License, or
      (at your option) any later version.

      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU General Public License for more details.

      You should have received a copy of the GNU  General Public License
      along with this program. If not, see http://www.gnu.org/licenses/.

  */

?><strong>Change village</strong><br/><br/><?php

  define("MODULE_OK", 1);
  if (!defined("MAIN_UNIT")) die("h4xx0r");
  global $txt;
  
  $vill = travian_return_villages($txt, True);

  if (empty($req["return"])) $req["return"] = "main";
  else $req["return"] = htmlspecialchars($req["return"]);
  
  $pstr = NULL;
  foreach ($req as $key => $value)
  {
    if (($key == "mod") || ($key == "return") || ($key == "SID")) continue;
    $pstr .= '&amp;'.urlencode($key).'='.urlencode($value);
  }

  if (!$vill["single"])
  {
    for ($i = 1; $i <= $vill["count"]; $i++)
    {
      if (defined("DISPLAY_GTVO")) print_link('main.php?mod=direct_call&amp;newdid='.$vill[$i]["id"].'&amp;file=dorf2&amp;return=village_look'.ps(), "&gt;", " ");
      print_link('main.php?mod=direct_call&amp;newdid='.$vill[$i]["id"].'&amp;file=dorf1&amp;return='.$req["return"].$pstr.ps(), $vill[$i]["name"], "<br/>");
      echo "[{$vill[$i]["x"]} {$vill[$i]["y"]}] ";
      if ($vill[$i]["active"])
      {
        echo "Active";
        $_SESSION["village"] = $vill[$i]["name"];
      }
      echo "<br/>";
    }
  }
  else echo "You have only one village.<br/>";
  echo "<br/>";

